Skip to content

Add DI integration with ServiceCollectionExtensions.AddDrivelution() - #291

Merged
JusterZhu merged 1 commit into
masterfrom
feature/di-integration-issue-290
May 23, 2026
Merged

Add DI integration with ServiceCollectionExtensions.AddDrivelution()#291
JusterZhu merged 1 commit into
masterfrom
feature/di-integration-issue-290

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Summary

Add Microsoft.Extensions.DependencyInjection integration so consumers can register Drivelution with services.AddDrivelution().

Changes

  • ServiceCollectionExtensions.AddDrivelution() extension method
  • Registers ICommandRunner, IDriverValidator, IDriverBackup, IGeneralDrivelution per platform
  • Supports DrivelutionOptions configuration via Action delegate
  • GeneralDrivelution.Create(IServiceProvider) overload for DI resolution
  • Falls back to factory-created instance when not registered in DI
  • Added Microsoft.Extensions.DependencyInjection.Abstractions package reference

Usage

`csharp
// ASP.NET / Generic Host
builder.Services.AddDrivelution(options =>
{
options.DefaultRetryCount = 5;
options.DefaultTimeoutSeconds = 600;
options.UseExponentialBackoff = true;
});

// Consumer
public class MyService(IGeneralDrivelution updater) { ... }

// Static facade with DI
var updater = GeneralDrivelution.Create(serviceProvider);
`

Backward Compatibility

Static GeneralDrivelution.Create() and GeneralDrivelution.Create(DrivelutionOptions?) still work — no breaking changes.

Closes #290

…s.AddDrivelution()

- Add ServiceCollectionExtensions.AddDrivelution() for DI registration
- Register ICommandRunner, IDriverValidator, IDriverBackup, IGeneralDrivelution per platform
- Support DrivelutionOptions configuration via Action delegate
- GeneralDrivelution.Create(IServiceProvider) overload for DI resolution
- Falls back to factory-created instance if not registered in DI
- Add Microsoft.Extensions.DependencyInjection.Abstractions package reference

Closes #290
Copilot AI review requested due to automatic review settings May 23, 2026 11:10
@JusterZhu
JusterZhu merged commit 655f2ee into master May 23, 2026
1 check failed
@JusterZhu
JusterZhu deleted the feature/di-integration-issue-290 branch May 23, 2026 11:10
@JusterZhu
JusterZhu removed the request for review from Copilot May 23, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add DI integration with ServiceCollectionExtensions

1 participant